{include file='common/head'}
<script>
    document.title = "申请友联 | {:config('system.base.title')} "
</script>
<style>
    .layout {
        background-color: #fff;
    }

    .captcha {
        width: 100px;
        height: 40px;
    }
    .panel{
        background: rgb(255, 255, 249) none repeat scroll 0% 0%;
        padding: 20px;
        border-radius: 5px;
        color: #6b7386;
        border: 1px solid rgb(249, 231, 224);
    }
</style>
<div class="layout">
    <p class="s-text">申请友联</p>
    <div>
        <div  class="panel layui-margin-3">
            1、正规网站，不违反法律的，不能涉及黄赌毒等内容；<br><br>
            2、已将本站【{:config('system.base.title')}】添加友链；<br><br>
            3、不能是新网站，网站内容不完善的，不予收录；；<br><br>
            4、网站广告不能太多，毫无体验感的站点不给予收录；；<br><br>
            5、提交后等待审核，若信息不真实或违反规定，本站有权取消收录不予通知。<br><br>
            注：新站提交前务必先搜索贵站名称，查询是否已收录。请勿重复提交！；
        </div>
    </div>
    <form class="layui-form layui-form-pane" action="" lat-filter="apply">
        <div class="layui-form-item">
            <label class="layui-form-label">网页名称</label>
            <div class="layui-input-block">
                <input type="text" name="web_name" autocomplete="off" placeholder="请输入网页名称" lay-verify="required"
                    class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">网页链接</label>
            <div class="layui-input-block">
                <input type="text" name="web_href" autocomplete="off" placeholder="请输入网页链接" lay-verify="required"
                    class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">网页描述</label>
            <div class="layui-input-block">
                <textarea name="web_description" placeholder="请输入网页描述" class="layui-textarea"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-row">
                <div class="layui-col-xs8">
                    <label class="layui-form-label">验证码</label>
                    <div class="layui-input-block">
                        <input type="text" name="captcha" value="" lay-verify="required" placeholder="验证码"
                            lay-reqtext="请填写验证码" autocomplete="off" class="layui-input" lay-affix="clear">
                    </div>
                </div>
                <div class="layui-col-xs4">
                    <div style="margin-left: 10px;">
                        <img class="captcha" src="{:captcha_src()}" id="captcha">
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <button class="layui-btn layui-btn-sm layui-bg-blue " lay-submit lay-filter="apply">提交</button>
        </div>
    </form>

</div>
{include file='common/bottom'}
<script>
    layui.use(function () {
        var form = layui.form;
        var layer = layui.layer;
        $ = layui.$;
        // 提交事件
        form.on('submit(apply)', function (data) {
            var field = data.field; // 获取表单字段值
            $.post("{:url('/index/link/doApply')}", field, (res) => {
                if (res.code == 200) {
                    layer.msg('提交成功，请耐心等待审核！', { icon: 6 })
                } else {
                    layer.msg(res.message, { icon: 5 })
                    let captcha = '/captcha.html?id=' + new Date().getTime()
                    $('#captcha').attr('src', captcha)
                }
            })
            return false; // 阻止默认 form 跳转
        });

    });
    $('#captcha').click(function (it) {
        let captcha = '/captcha.html?id=' + new Date().getTime()
        $(this).attr('src', captcha)
    })
</script>